/**
 * 获取本地图
 * @param folder // 文件夹名字 如 /static/images/home
 * @param fileName // 文件名 如 home-bg
 * @param format // 文件类型 如 png jpg
 * @returns {*|string}
 */

const urlTobase64 = (folder, fileName, format = "png") => {
	// #ifdef MP-WEIXIN
	// let img = `/static/image/${fileName}.${format}`,
	let img = folder,
		imgBase64 = uni.getFileSystemManager().readFileSync(img, "base64"),
		base64Url = `data:image/png;base64,${imgBase64}`

	return base64Url
	// #endif

	// #ifdef APP-PLUS || H5
	return folder
	// #endif
}


function textOfAmountType(input) {
	let obj = {
		1: "其它",
		2: "优惠券抵扣",
		3: "优惠活动抵扣",
		4: "工人薪资构成-基础薪资",
		5: "工人薪资构成-综合绩效增加部分",
		6: "工人薪资构成-技能证书增加部分",
		7: "加班/节假日/调度 费用",
		8: "平台管理费-日收",
		9: "平台管理费-百分比",
		10: "工人技能培训费",
		11: "工人的个税"
	}
	return obj[input] === undefined ? '' : obj[input]
}

// 获取当前模式
async function getClient() {
	let client = "";
	// #ifdef APP-PLUS
	const systemInfo = await uni.getSystemInfoSync();
	if (systemInfo.platform === 'android') {
		client = 'android'
	} else if (systemInfo.platform === 'ios') {
		client = 'ios'
	}
	// #endif

	// #ifdef H5
	client = 'h5'
	// #endif

	// #ifdef MP-WEIXIN
	client = 'wx_mini'
	// #endif
	
	return client
}

export default {
	urlTobase64,
	textOfAmountType,
	getClient
}